Skip to content

Add Across Predict withdraw submit support#8761

Open
pedronfigueiredo wants to merge 1 commit into
mainfrom
pnf/predict-withdraw-across-submit
Open

Add Across Predict withdraw submit support#8761
pedronfigueiredo wants to merge 1 commit into
mainfrom
pnf/predict-withdraw-across-submit

Conversation

@pedronfigueiredo
Copy link
Copy Markdown
Contributor

@pedronfigueiredo pedronfigueiredo commented May 11, 2026

Summary

This is PR 3 of 4 in the core stack for Predict withdraws over Across.

  • Prepends the original Predict withdraw transaction when submitting post-quote Across flows.
  • Uses TransactionType.predictAcrossWithdraw for the Across deposit leg.
  • Forces 7702 batch submission when the parent withdraw transaction already has an authorization list.
  • Estimates final 7702 submit gas when the submit-time batch shape differs from the quote-time batch shape.
  • Moves original transaction gas parsing into a shared Across helper used by quote and submit paths.

Stack

  1. Add Across Predict withdraw plumbing #8759: plumbing to identify Predict Across withdraws
  2. Add Across Predict withdraw quote support #8760: quote support
  3. This PR: submit support
  4. Fix Across Predict withdraw gas payment edges #8762: gas payment edge cases

Validation

  • yarn workspace @metamask/transaction-pay-controller run jest --no-coverage src/strategy/across/across-submit.test.ts src/strategy/across/across-quotes.test.ts src/strategy/across/AcrossStrategy.test.ts
  • Full stack validation was run on the final stacked branch:
    • yarn changelog:validate
    • yarn workspace @metamask/transaction-pay-controller run test
    • yarn workspace @metamask/transaction-controller run test

Note

Medium Risk
Changes Across submission batching and EIP-7702 gas handling for post-quote Predict withdraws, which can affect transaction construction and gas limits. Risk is mitigated by extensive new unit coverage but still touches critical submit-path logic.

Overview
Adds Across submit-time support for post-quote Predict withdraws by prepending the original withdraw transaction into the submitted batch and using TransactionType.predictAcrossWithdraw for the Across leg.

Updates 7702 batching logic to force 7702 submission when needed (quoted 7702, parent authorizationList, or gas-fee-token post-quote Predict withdraw), and to estimate a final gasLimit7702 via TransactionController:estimateGasBatch when the submit batch shape differs from the quote.

Refactors original gas parsing into shared getOriginalTransactionGas (moved from across-quotes.ts to transactions.ts), ensures excludeNativeTokenForFee is passed when using a gasFeeToken, and expands across-submit tests to cover these new post-quote/7702 scenarios. Also updates the package changelog entry.

Reviewed by Cursor Bugbot for commit 1fb74a1. Bugbot is set up for automated code reviews on this repo. Configure here.

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-submit branch from 4735d17 to 0e2bce3 Compare May 11, 2026 11:29
@pedronfigueiredo pedronfigueiredo self-assigned this May 11, 2026
@pedronfigueiredo pedronfigueiredo marked this pull request as ready for review May 11, 2026 13:33
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners May 11, 2026 13:33
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from f4feefb to 86b0f66 Compare May 11, 2026 13:54
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-submit branch from 0e2bce3 to 013d596 Compare May 11, 2026 13:55
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from 86b0f66 to 9fda0ef Compare May 12, 2026 09:58
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-submit branch from 013d596 to 2b8de19 Compare May 12, 2026 09:59
pull Bot pushed a commit to dmrazzy/core that referenced this pull request May 12, 2026
## Summary

This is PR 1 of 4 in the core stack for Predict withdraws over Across.

- Adds `TransactionType.predictAcrossWithdraw`.
- Treats `isPostQuote` requests as actionable for Across support checks.
- Allows source-chain authorization lists only for post-quote Predict
withdraw detection, where the original withdraw is not encoded as an
Across destination action.
- Generalizes transaction-pay refund documentation from Relay-only
language to quote-provider language.

## Stack

1. This PR: plumbing to identify Predict Across withdraws
2. MetaMask#8760: quote support
3. MetaMask#8761: submit support
4. MetaMask#8762: gas payment edge cases

## Validation

- `yarn workspace @metamask/transaction-pay-controller run jest
--no-coverage src/strategy/across/AcrossStrategy.test.ts`
- Full stack validation was run on the final stacked branch:
  - `yarn changelog:validate`
  - `yarn workspace @metamask/transaction-pay-controller run test`
  - `yarn workspace @metamask/transaction-controller run test`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes Across quote eligibility logic to treat `isPostQuote` requests
as actionable and to allow EIP-7702 `authorizationList` only for a
specific Predict-withdraw post-quote path; misclassification could
incorrectly enable/disable Across quoting for some transactions.
> 
> **Overview**
> Introduces a new `TransactionType.predictAcrossWithdraw` to tag
Predict withdraws that will use Across.
> 
> Updates `AcrossStrategy.supports` to treat `isPostQuote` quote
requests as actionable and only accept them when the original
transaction is a Predict withdraw, plus adds
`hasUnsupportedTransactionAuthorizationList` to block EIP-7702
`authorizationList` usage except for the Predict-withdraw post-quote
detection case. Tests were extended to cover post-quote Predict withdraw
handling.
> 
> Minor docs/logic tweaks: `isAcrossQuoteRequest` now includes
`isPostQuote`, and `refundTo` comments were generalized from
Relay-specific wording to quote-provider wording.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
fc6f92e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from 9fda0ef to d4b3bee Compare May 12, 2026 13:24
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-submit branch from 2b8de19 to 0d353f0 Compare May 12, 2026 13:24
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from d4b3bee to a65c549 Compare May 12, 2026 16:26
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-submit branch from 0d353f0 to 131e283 Compare May 12, 2026 16:26
Base automatically changed from pnf/predict-withdraw-across-quotes to main May 13, 2026 09:46
pull Bot pushed a commit to dmrazzy/core that referenced this pull request May 13, 2026
## Summary

This is PR 2 of 4 in the core stack for Predict withdraws over Across.

- Adds Across quote construction for post-quote Predict withdraws.
- Uses exact-input quotes without destination actions for the post-quote
withdraw flow.
- Preserves provider fees, target totals, and original transaction gas
when normalizing quotes.
- Re-quotes post-quote withdraws after reserving source token for
source-chain gas paid with the source token.

## Stack

1. MetaMask#8759: plumbing to identify Predict Across withdraws
2. This PR: quote support
3. MetaMask#8761: submit support
4. MetaMask#8762: gas payment edge cases

## Validation

- `yarn workspace @metamask/transaction-pay-controller run jest
--no-coverage src/strategy/across/across-quotes.test.ts
src/strategy/across/AcrossStrategy.test.ts`
- Full stack validation was run on the final stacked branch:
  - `yarn changelog:validate`
  - `yarn workspace @metamask/transaction-pay-controller run test`
  - `yarn workspace @metamask/transaction-controller run test`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Medium risk because it changes Across quote construction and gas/fee
calculations for post-quote Predict withdraw flows, including
special-casing EIP-7702 authorization-list handling and multi-phase
re-quoting logic that could affect pricing and execution safety.
> 
> **Overview**
> Adds Across **quote support for post-quote Predict withdraws**,
switching these requests to `exactInput` quoting with **no destination
actions** and passing `refundAddress` through to the Across
`/swap/approval` request.
> 
> Updates gas/fee normalization to **include the original withdrawal
transaction’s gas** in `sourceNetwork`/`gasLimits` for post-quote
quotes, and extends the existing two-phase “reserve source token for
gas-fee-token” re-quote flow to *also* apply to post-quote Predict
withdraws (now failing hard on unsafe/invalid phase-2 outcomes instead
of falling back).
> 
> Relaxes Across strategy quote support checks to allow first-time
EIP-7702 `requiresAuthorizationList` **only** for post-quote Predict
withdraw quotes that have no embedded Across actions, and updates
types/tests accordingly (including persisting `actions` in the quote’s
`original.request`).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a65c549. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-submit branch from 131e283 to 1fb74a1 Compare May 13, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant